<template>
  <div class="inbound-container">
    <el-form :inline="true" label-width="120px" :model="form">
      <el-form-item label="调拨编码：">
        <div class="item">{{ form.Code }}</div>
      </el-form-item>
      <el-form-item label="调拨名称：">
        <div class="item">{{ form.FullName }}</div>
      </el-form-item>
      <el-form-item label="调拨编号：">
        <div class="item">{{ form.TONo }}</div>
      </el-form-item>
      <el-form-item label="金额单位：">
        <div class="item">{{ form.AmtUnit }}</div>
      </el-form-item>
      <el-form-item label="调拨类型：">
        <div class="item">
          {{
            form.TOType === '1'
              ? '内部调拨'
              : form.TOType === '2'
              ? '外部调拨'
              : ''
          }}
        </div>
      </el-form-item>
      <el-form-item label="编制单位：">
        <div class="item">{{ form.GroupName }}</div>
      </el-form-item>
      <el-form-item label="货主名称：">
        <div class="item">{{ form.OwnerName }}</div>
      </el-form-item>
      <el-form-item label="预期发货日期：">
        <div class="item">{{ form.DeliveryDate }}</div>
      </el-form-item>
      <el-form-item label="发货仓库：">
        <div class="item">{{ form.DeliverWH }}</div>
      </el-form-item>
      <el-form-item label="目的仓库：">
        <div class="item">{{ form.DestinationWH }}</div>
      </el-form-item>
      <el-form-item label="送货方式：">
        <div class="item">
          {{
            form.DeliveryType === '1'
              ? '自配送'
              : form.DeliveryType === '2'
              ? '外部配送'
              : ''
          }}
        </div>
      </el-form-item>
      <el-form-item label="预期到达日期：">
        <div class="item">{{ form.ArriveDate }}</div>
      </el-form-item>
      <el-form-item label="提货人员：">
        <div class="item">{{ form.CollectPerson }}</div>
      </el-form-item>
      <el-form-item label="发货人员：">
        <div class="item">{{ form.DeliveryPerson }}</div>
      </el-form-item>
      <el-form-item label="调拨状态：">
        <div class="item">{{ OptionTOStatus[form.TOStatus] || '' }}</div>
      </el-form-item>
      <el-form-item label="物资管理人员：">
        <div class="item">{{ form.ItemManager }}</div>
      </el-form-item>
    </el-form>
    <el-table ref="multipleTable" border :data="tableData">
      <el-table-column label="批次号" min-width="100" prop="BatchNo" />
      <el-table-column label="物资编码" min-width="100" prop="ItemCode" />
      <el-table-column label="物资名称" min-width="120" prop="ItemName" />
      <el-table-column label="物料规格" min-width="100" prop="ItemSepc" />
      <el-table-column label="物资代码" min-width="100" prop="MaterialCode" />
      <el-table-column label="计量单位" min-width="100" prop="ItemUnit" />
      <el-table-column label="应调拨数量" min-width="110" prop="Qty" />
      <el-table-column label="实调拨数量" min-width="110" prop="ActualQty" />
      <el-table-column label="单价" min-width="90" prop="Price" />
      <el-table-column label="金额" min-width="90" prop="Amt" />
      <el-table-column label="代理费" min-width="100" prop="ProxyAmt" />
      <el-table-column label="其他费用" min-width="100" prop="OtherAmt" />
      <el-table-column label="合计金额" min-width="100" prop="TotalAmt" />
    </el-table>
    <div class="pagination">
      <el-pagination
        background
        :current-page="pageNo"
        :layout="'total, sizes, prev, pager, next, jumper'"
        :page-size="pageSize"
        :total="total"
        @current-change="handleCurrentchiled"
        @size-change="handleSizechiled"
      />
    </div>
  </div>
</template>

<script lang="ts" setup>
  import { ref } from 'vue'
  import { TransferOrderDetail } from '@/api/form'

  const props = defineProps<{
    id: string
  }>()
  const OptionTOStatus: any = ref({
    '0': '已完成',
    '1': '进行中',
    '2': '未开始',
  })
  const form: any = ref({})
  const tableData: any = ref([])
  const id = props.id || ''
  const pageNo = ref(1)
  const pageSize = ref(10)
  const total = ref(0)
  const getTableData = async () => {
    const params = {
      pageNo: 1,
      pageSize: 10,
      total: 0,
      tableName: '',
      sort: '',
      order: '',
      wheres: '',
      export: true,
      value: id,
    }
    const data = await TransferOrderDetail(params)
    tableData.value = data.rows || []
    form.value = data.master || {}
  }
  const handleCurrentchiled = (val: number) => {
    pageNo.value = val
  }
  const handleSizechiled = (val: number) => {
    pageSize.value = val
  }

  onMounted(() => {
    getTableData()
  })
</script>

<style lang="scss" scoped>
  .inbound-container {
    .item {
      width: 160px;
    }
  }
</style>
